<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    const worker = new Worker('./worker.js')
    worker.addEventListener('message', e => { // 监听worker消息
      console.log(e, '===');
      
    })
    worker.addEventListener('error', err => { // 监听错误，worker内部出现错误触发
      console.log(err, 'worker内部出现错误触发');
      
    })
    worker.addEventListener('messageerror', err => { // message接收到无法被反序列化的参数时候触发
      console.log(err.message, '接收到无法被反序列化的参数时候触发');
      
    })
    // worker.postMessage('你好我是主线程')
  </script>
</body>
</html>